const mysql = require('mysql');
const connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'books'
});

connection.connect();

// connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
//     if (error) throw error;
//     console.log('The solution is: ', results[0].solution);
// });

connection.query('SELECT * from t_book', function (error, results, fields) {
    if (error) throw error;
    if (results && Array.isArray(results)) {
        results.forEach((item) => {
            console.log(item.id, item.name, item.author, item.category, item.description);
        });
    }

    connection.end();
});

// connection.end();